<?php
namespace app\controller\api\cms;

use app\BaseController;
use app\model\SlideModel;
use app\model\SlideInfoModel;
use app\model\BannerModel;
use app\model\BannerImageModel;
class Home extends BaseController
{

    public function slide(){

        $slide = SlideModel::where('name','home')->find();

        $list = SlideInfoModel::where('slide_id',$slide->id)->order('sort_order','desc')->select();

        return json( $list );

    }

    public function banner(){

        $banner = BannerModel::where([
            'position'=>'home',
            'platform'=>'pc',
            'status'=>1,
            ])->find();

        $list = BannerImageModel::where('banner_id',$banner->banner_id)->order('sort_order','desc')->select();

        foreach($list as &$item){

            $item['src'] = $item['image'];
        }
        return json( $list );

    }

}